package com.rajaev.dtu.tractor.domain.vo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.HashSet;

/**
 * @Created with IDEA
 * @author: tianjie
 * @Date:2019/4/8
 * @Time:18:09
 */
@Data
@NoArgsConstructor
public class FaultDetailVo {

    private Integer faultId;

    private int faultCode;

    private String vin;

    private int  faultLevel;

    private String faultDesc;

    private Date startTime;

    private Date endTime;

    private String state;

    private Integer batteryId;

    private String terId;

    @Override
    public int hashCode() {
        return (faultCode+""+terId+""+state).hashCode();
    }

    @Override
    public boolean equals(Object target) {
        FaultDetailVo faultDetailVo = (FaultDetailVo) target;
        if (faultDetailVo.getFaultCode() == (this.faultCode)
        && faultDetailVo.getTerId().equals(this.terId)
        && faultDetailVo.getState().equalsIgnoreCase(this.state)) {
            return true;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        FaultDetailVo faultDetailVo = new FaultDetailVo();
        faultDetailVo.setFaultCode(100);
        faultDetailVo.setBatteryId(1);
        faultDetailVo.setState("0");

        FaultDetailVo faultDetailVo2 = new FaultDetailVo();
        faultDetailVo2.setFaultCode(100);
        faultDetailVo2.setBatteryId(1);
        faultDetailVo2.setState("0");
        HashSet<FaultDetailVo> hashSet = new HashSet<>();
        hashSet.add(faultDetailVo);
        hashSet.add(faultDetailVo2);
        System.out.println(hashSet.size());
    }

}
